<template>
  <view class="page-container">
    <ForecastMaintenance :stcd="stcd" v-if="stcd" />
    <view class="error-page" v-else>
      <text class="error-icon">⚠️</text>
      <text class="error-title">缺少测站参数</text>
      <text class="error-desc">请通过URL传入stcd参数</text>
      <text class="error-example">示例: /pages/forecast-maintenance/index?stcd=12345678</text>
    </view>
  </view>
</template>

<script>
import { ref, onMounted } from 'vue'
import ForecastMaintenance from '@/components/ForecastMaintenance/index.vue'

export default {
  name: 'ForecastMaintenancePage',
  components: {
    ForecastMaintenance
  },
  setup() {
    const stcd = ref('')

    onMounted(() => {
      // 获取URL参数
      const pages = getCurrentPages()
      const currentPage = pages[pages.length - 1]
      const options = currentPage.options || {}
      
      stcd.value = options.stcd || ''
      
      // 如果没有stcd参数，提示用户
      if (!stcd.value) {
        console.warn('未提供stcd参数')
      }
    })

    return {
      stcd
    }
  }
}
</script>

<style scoped>
.page-container {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.error-page {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background-color: #f5f7fa;
}

.error-icon {
  font-size: 64px;
}

.error-title {
  font-size: 24px;
  font-weight: 600;
  color: #303133;
}

.error-desc {
  font-size: 16px;
  color: #606266;
}

.error-example {
  font-size: 14px;
  color: #909399;
  font-family: 'Monaco', 'Courier New', monospace;
  padding: 8px 16px;
  background-color: #fff;
  border-radius: 4px;
  border: 1px solid #e4e7ed;
}
</style>

